
package cn.byapps.hw;

import cn.byapps.hw.dao.HomeworkDao;
import cn.byapps.hw.dao.HomeworkFileDao;
import cn.byapps.hw.dto.HomeWorkDTO;
import cn.byapps.hw.schedule.TaskCoudFileStore;
import cn.byapps.hw.service.TimetableService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.util.List;

/**
 * HwApplicationTest01
 */
@SpringBootTest
public class HwApplicationTest01 {

    @Resource
    private HomeworkDao homeworkDao;

    @Resource
    private HomeworkFileDao homeworkFileDao;

    @Resource
    private TimetableService timetableService;

    @Resource
    private TaskCoudFileStore taskCoudFileStore;

    // @Test
    // public void testHomeWorkDao() {
    //     List<Object[]> objs = homeworkDao.getHomeworkByClazzAndCourse(2, 3);
    //     for (Object[] obj : objs) {
    //         System.out.println(obj[0] + " = " + obj[1] + " = " + obj[2]);
    //     }
    // }

    @Test
    public void testHomeWorkDao2() {
        List<HomeWorkDTO> objs = homeworkDao.getHomeWorkDTO(2, 3);
        for (HomeWorkDTO obj : objs) {
            System.out.println(obj.getId() + "--" + obj.getName() + "--" + obj.getCount());
        }
    }

    // @Test
    // public void testHomeWorkDao3() {
    //     List<Object[]> objs = homeworkDao.getAllStudentUpload(2, 3);
    //     for (Object[] obj : objs) {
    //         System.out.println(obj[0] + " = " + obj[1] + " = " + obj[2]);
    //     }
    //     System.out.println(objs.size());
    // }

    @Test
    public void testHomeWorkDao4() {
        List<Object[]> objs = homeworkDao.getAllHomeWorkFileDTO(2, 3);
        for (Object[] obj : objs) {
            System.out.println(obj[0] + " = " + obj[1] + " = " + obj[2]);
        }
        System.out.println(objs.size());
    }

    @Test
    void test() {
        /*Date now = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        List<HomeworkFile> homeworkFiles = homeworkFileDao.findAll();
        for (HomeworkFile h:homeworkFiles){
            Date data = h.getFileDate();
            long betweenDate = (now.getTime() - data.getTime())/(60*60*24*1000);
            if (betweenDate > 365){
                //System.out.println(h.getFileName()+"-"+h.getFilePath()+"-"+h.getMd5());
                System.out.println(h.getFilePath().substring(23));
            }
        }*/
        //taskCoudFileStore.getAll();
        /*taskCoudFileStore.tranforeFile();
        taskCoudFileStore.tranforeTeacherFile();
        taskCoudFileStore.deleteOldFile();*/
    }
}